<template>
  <button
    ref="_ref"
    class="v-button"
    :class="{
      [`v-button--${type}`]: type,
      [`v-button--${size}`]: size,
      'is-plain': plain,
      'is-round': round,
      'is-circle': circle,
      'is-disabled': disabled,
      'is-loading': loading,
    }"
    :disabled="disabled || loading"
    :autofocus="autofocus"
    :type="nativeType"
  >
    <Icon icon="fa-spinner" spin v-if="loading" />
    <Icon :icon="icon" v-if="icon" />
    <span>
      <slot></slot>
    </span>
  </button>
</template>

<script lang="ts" setup>
import type { ButtonProps } from './types'
import { ButtonSizeEnum } from './enum'
import Icon from '../Icon/Icon.vue'
import { ref } from 'vue'
// import { buttonProps } from './types'
withDefaults(defineProps<ButtonProps>(), {
  size: ButtonSizeEnum.normal,
  plain: false,
  round: false,
  circle: false,
  disabled: false,
  nativeType: 'button',
})
// defineProps(buttonProps)
defineOptions({ name: 'VButton' })

const _ref = ref<HTMLButtonElement>()
defineExpose({
  ref: _ref,
})
</script>
<style scoped></style>
